 package com.lbs.core.shared.parsing;
 
 import com.lbs.core.shared.XmlRawInterface;
import com.lbs.core.shared.tables.AbstractData;
import java.util.ArrayList;
import java.util.List;
 
 public class LbsIfToken
   implements LbsTokenInterface
 {
   private LbsCondition condition;
   private LbsBasicToken ifTrue;
   private LbsBasicToken ifFalse;
 
   public LbsIfToken(String string, XmlRawInterface xml, AbstractData data)
     throws LbsParserException
   {
     String cond = string.substring(0, string.indexOf("?"));
     condition = new LbsCondition(cond, xml, data);
 
     String trueVal = string.substring(string.indexOf("?") + 1, string.indexOf(" : "));
     trueVal = trueVal.trim();
     String falseVal = string.substring(string.indexOf(" : ") + 3);
     falseVal = falseVal.trim();
     ifTrue = new LbsBasicToken(trueVal, xml, data);
     ifFalse = new LbsBasicToken(falseVal, xml, data);
   }
 
   @Override
public Object getVal()
   {
     if (condition.getResult().booleanValue()) {
       return ifTrue.getVal();
     }
     return ifFalse.getVal();
   }
 
   @Override
public List<String> getFields()
   {
     List<String> result = new ArrayList<String>();
     result.addAll(condition.getFields());
     result.addAll(ifTrue.getFields());
     result.addAll(ifFalse.getFields());
     return result;
   }
 }

